(function(Global /*, context */) {





    function formatTime (time) {
    var seconds = time % 60;
    if (seconds >= 0) {
        return [Math.floor(time / 60), seconds < 10 ? '0' + seconds : seconds].join(':');
    } else {
        seconds = Math.abs(seconds);
        return ['-' + Math.floor(time / 60), seconds < 10 ? '0' + seconds : seconds].join(':');
    }
}



    var topBar =null



    function UpdateClock () {
           if(Global.Panel.playerInfo){
               Global.Panel.playerInfo.OnToggle({isOpen:GameUI.IsAltDown()})
           }

        var rawTime = Game.GetDOTATime(false, true);
        var time = Math.floor(rawTime);
        var isNSNight = rawTime <  -Number.MAX_VALUE;
        var timeThisDayLasts = time - (Math.floor(time / 600) * 600);
        var isDayTime = !isNSNight && timeThisDayLasts <= 300;

        // $.Msg(time)
        if(topBar===null){
            topBar= Global.Panel.dotaHud.FindChildTraverse('topbar');
        }



        $('#TimeHider').style.visibility = 'visible';
        $('#GameTime').text = formatTime(time, true);
        var dayTime = $('#DayTime');
        var nightTime = $('#NightTime');
        var nightstalkerNight = $('#NightstalkerNight');
        dayTime.style.visibility = 'collapse';
        nightTime.style.visibility = 'collapse';
        nightstalkerNight.style.visibility = 'collapse';
        if (isDayTime) {
            dayTime.style.visibility = 'visible';
        } else if (isNSNight) {
            nightstalkerNight.style.visibility = 'visible';
        } else {
            nightTime.style.visibility = 'visible';
        }
        $.Schedule(0.2, UpdateClock);
    }

    UpdateClock();



})(GameUI.CustomUIConfig(), this);